/*  1:   */ package org.intellij.lang.regexp.psi.impl;
/*  2:   */ 
/*  3:   */

import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.search.PsiElementProcessor.FindFilteredElement;
import com.intellij.psi.util.PsiElementFilter;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.RegExpElementVisitor;
import org.intellij.lang.regexp.psi.RegExpGroup;
import org.intellij.lang.regexp.psi.RegExpPyNamedGroupRef;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */
/* 18:   */
/* 19:   */ 
/* 20:   */ public class RegExpPyNamedGroupRefImpl
/* 21:   */   extends RegExpElementImpl
/* 22:   */   implements RegExpPyNamedGroupRef
/* 23:   */ {
/* 24:   */   public RegExpPyNamedGroupRefImpl(ASTNode paramASTNode)
/* 25:   */   {
/* 26:41 */     super(paramASTNode);
/* 27:   */   }
/* 28:   */   
/* 29:   */   public void accept(RegExpElementVisitor paramRegExpElementVisitor)
/* 30:   */   {
/* 31:46 */     paramRegExpElementVisitor.visitRegExpPyNamedGroupRef(this);
/* 32:   */   }
/* 33:   */   
/* 34:   */   @Nullable
/* 35:   */   public RegExpGroup resolve()
/* 36:   */   {
/* 37:51 */     PsiElementProcessor.FindFilteredElement localFindFilteredElement = new PsiElementProcessor.FindFilteredElement(new PsiElementFilter()
/* 38:   */     {
/* 39:   */       public boolean isAccepted(PsiElement paramAnonymousPsiElement)
/* 40:   */       {
/* 41:53 */         if (((paramAnonymousPsiElement instanceof RegExpGroup)) && 
/* 42:54 */           (((RegExpGroup)paramAnonymousPsiElement).isPythonNamedGroup()) && (Comparing.equal(RegExpPyNamedGroupRefImpl.this.getGroupName(), ((RegExpGroup)paramAnonymousPsiElement).getGroupName()))) {
/* 43:55 */           return true;
/* 44:   */         }
/* 45:58 */         return paramAnonymousPsiElement == RegExpPyNamedGroupRefImpl.this;
/* 46:   */       }
/* 47:61 */     });
/* 48:62 */     PsiTreeUtil.processElements(getContainingFile(), localFindFilteredElement);
/* 49:63 */     if ((localFindFilteredElement.getFoundElement() instanceof RegExpGroup)) {
/* 50:64 */       return (RegExpGroup)localFindFilteredElement.getFoundElement();
/* 51:   */     }
/* 52:66 */     return null;
/* 53:   */   }
/* 54:   */   
/* 55:   */   @Nullable
/* 56:   */   public String getGroupName()
/* 57:   */   {
/* 58:71 */     ASTNode localASTNode = getNode().findChildByType(RegExpTT.NAME);
/* 59:72 */     return localASTNode != null ? localASTNode.getText() : null;
/* 60:   */   }
/* 61:   */   
/* 62:   */   public PsiReference getReference()
/* 63:   */   {
/* 64:77 */     new PsiReference()
/* 65:   */     {
/* 66:   */       public PsiElement getElement()
/* 67:   */       {
/* 68:79 */         return RegExpPyNamedGroupRefImpl.this;
/* 69:   */       }
/* 70:   */       
/* 71:   */       public TextRange getRangeInElement()
/* 72:   */       {
/* 73:83 */         return new TextRange(4, RegExpPyNamedGroupRefImpl.this.getTextLength() - 1);
/* 74:   */       }
/* 75:   */       
/* 76:   */       public PsiElement resolve()
/* 77:   */       {
/* 78:87 */         return RegExpPyNamedGroupRefImpl.this.resolve();
/* 79:   */       }
/* 80:   */       
/* 81:   */       @NotNull
/* 82:   */       public String getCanonicalText()
/* 83:   */       {
/* 84:92 */         String tmp14_11 = getRangeInElement().substring(RegExpPyNamedGroupRefImpl.this.getText());
/* 85:92 */         if (tmp14_11 == null) {
/* 86:92 */           throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpPyNamedGroupRefImpl$2", "getCanonicalText" }));
/* 87:   */         }
/* 88:92 */         return tmp14_11;
/* 89:   */       }
/* 90:   */       
/* 91:   */       public PsiElement handleElementRename(String paramAnonymousString)
/* 92:   */         throws IncorrectOperationException
/* 93:   */       {
/* 94:96 */         throw new UnsupportedOperationException();
/* 95:   */       }
/* 96:   */       
/* 97:   */       public PsiElement bindToElement(@NotNull PsiElement paramAnonymousPsiElement)
/* 98:   */         throws IncorrectOperationException
/* 99:   */       {
/* :0::0 */         if (paramAnonymousPsiElement == null) {
/* :1::0 */           throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/psi/impl/RegExpPyNamedGroupRefImpl$2", "bindToElement" }));
/* :2:   */         }
/* :3::0 */         throw new UnsupportedOperationException();
/* :4:   */       }
/* :5:   */       
/* :6:   */       public boolean isReferenceTo(PsiElement paramAnonymousPsiElement)
/* :7:   */       {
/* :8::4 */         return resolve() == paramAnonymousPsiElement;
/* :9:   */       }
/* ;0:   */       
/* ;1:   */       @NotNull
/* ;2:   */       public Object[] getVariants()
/* ;3:   */       {
/* ;4::9 */         Object[] tmp3_0 = ArrayUtil.EMPTY_OBJECT_ARRAY;
/* ;5::9 */         if (tmp3_0 == null) {
/* ;6::9 */           throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpPyNamedGroupRefImpl$2", "getVariants" }));
/* ;7:   */         }
/* ;8::9 */         return tmp3_0;
/* ;9:   */       }
/* <0:   */       
/* <1:   */       public boolean isSoft()
/* <2:   */       {
/* <3:;3 */         return false;
/* <4:   */       }
/* <5:   */     };
/* <6:   */   }
/* <7:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.psi.impl.RegExpPyNamedGroupRefImpl

 * JD-Core Version:    0.7.0.1

 */